/**
 * 全局参数文件
 * use	存放全局的静态参数，方法和接口地址
 * by zhoukuan
 * date 18/10/24
 */

var IP_ADDRESS="meteo.awit.net.cn";
var PORT="10280";
//var IP_ADDRESS="192.168.137.1";
//var PORT="8080";

var PROJECT="/GuiYang_weather_BS";
var SITE_HEAD="http://"+IP_ADDRESS+":"+PORT+PROJECT;

//登录
var API_LOGIN_URL = SITE_HEAD+"/login.do?doLogin";
//检查更新
var UPDATE_URL = SITE_HEAD+"/appUpdate.do?appVersion&file_panel=1";
//气象站地图标注点
var WEATHER_STATION_MAP_MAKERS = SITE_HEAD+"/weatherData.do?getActivedStation";
//预报点列表
var FORCAST_LIST = SITE_HEAD+"/weatherData.do?getActivedForcast";
//预报数据
var FORCAST_DATA = SITE_HEAD+"/weatherData.do?getWeatherData";
//气象站图例
var WEATHER_MAP = "http://"+IP_ADDRESS+":"+PORT+"/";
//气象站详情
var WEATHER_STATION_INFO = SITE_HEAD+"/weatherData.do?getStationInfo&station_code=";
//预报点类型数据
var FORCAST_DETAIL_DATA = SITE_HEAD+"/weatherData.do?forcastTypeData";
//更新包下载
var mDownloadUrl= SITE_HEAD+"/upload/appfile/";
//全部气象站数据
var stationDatas = SITE_HEAD+"/weatherData.do?getActivedStation";
//预报历史数据查询
var getForcastHistory =SITE_HEAD+"/weatherData.do?getHistoryData";
//24h降雨降雪查询
var DIS_DATA = SITE_HEAD+'/weatherData.do?getDisaster';
//气象站统计图数据接口
var STATION_ECHART_DATA=SITE_HEAD+'/weatherData.do?getStationEchart';

//气象站历史数据查询
var getStationHistory = SITE_HEAD+"/weatherData.do?getStationHistory"
///weatherData.do?getStationHistory&station_code=18110019001?data_time=2018-11-30

var WIND_ARR_DICT=[
	{text:'北',cod:'N',sr:348.76,er:11.25},
	{text:'北东北',cod:'NNE',sr:11.26,er:33.75},
	{text:'东北',cod:'NE',sr:33.76,er:56.25},
	{text:'东东北',cod:'ENE',sr:56.26,er:78.75},
	{text:'东',cod:'E',sr:78.76,er:101.25},
	{text:'东东南',cod:'ESE',sr:101.26,er:123.75},
	{text:'东南',cod:'SE',sr:123.76,er:146.25},
	{text:'南东南',cod:'SSE',sr:146.26,er:168.75},
	{text:'南',cod:'S',sr:168.26,er:191.25},
	{text:'南西南',cod:'SSW',sr:191.26,er:213.75},
	{text:'西南',cod:'SW',sr:213.76,er:236.25},
	{text:'西西南',cod:'WSW',sr:236.26,er:258.75},
	{text:'西',cod:'W',sr:258.76,er:281.25},
	{text:'西西北',cod:'WNW',sr:281.26,er:303.75},
	{text:'西北',cod:'NW',sr:303.76,er:326.25},
	{text:'北西北',cod:'NNW',sr:326.26,er:348.75}
];
var WIND_SU_DICT=[
	{level:0,ss:0,es:0.2},
	{level:1,ss:0.3,es:1.5},
	{level:2,ss:1.6,es:3.3},
	{level:3,ss:3.4,es:5.4},
	{level:4,ss:5.5,es:7.9},
	{level:5,ss:8.0,es:10.7},
	{level:6,ss:10.8,es:13.8},
	{level:7,ss:13.9,es:17.1},
	{level:8,ss:17.2,es:20.7},
	{level:9,ss:20.8,es:24.4},
	{level:10,ss:24.5,es:28.4},
	{level:11,ss:28.5,es:32.6},
	{level:12,ss:32.7,es:36.9},
	{level:13,ss:37.0,es:41.4},
	{level:14,ss:41.5,es:46.1},
	{level:15,ss:46.2,es:50.9},
	{level:16,ss:51.0,es:56.0},
	{level:17,ss:56.1,es:null}
];

//灾害等级
var DIS_AREA=[
	[		//freez
		{
			min:0,
			max:1,
			text:'凝冻黄色预警',
			src:'images/warn/freez_yellow.png'
		},{
			min:1,
			max:2,
			text:'凝冻橙色预警',
			src:'images/warn/freez_orange.png'
		},{
			min:2,
			max:3,
			text:'凝冻红色预警',
			src:'images/warn/freez_red.png'
		}
	],[		//wu
		{
			min:0.25,
			max:0.5,
			text:'大雾黄色预警',
			src:'images/warn/wu_yellow.png'
		},{
			min:0.1,
			max:0.25,
			text:'大雾橙色预警',
			src:'images/warn/wu_orange.png'
		},{
			min:-1,
			max:0.1,
			text:'大雾红色预警',
			src:'images/warn/wu_red.png'
		}
	],[		//rain
		{
			min:29.999,
			max:70,
			text:'暴雨黄色预警',
			src:'images/warn/baoyu_yellow.png'
		},{
			min:70,
			max:140,
			text:'暴雨橙色预警',
			src:'images/warn/baoyu_orange.png'
		},{
			min:140,
			max:100000,
			text:'暴雨红色预警',
			src:'images/warn/baoyu_red.png'
		}
	]
]


//24h
var CLOUD_AREA=[
	{text:'晴',min:0,max:50,src:'images/weather-fine.png'},
	{text:'多云',min:50,max:90,src:'images/weather-cloud1.png'},
	{text:'阴',min:90,max:100000,src:'images/weather-overcast.png'}
]
var SNOW_AREA=[
	{text:'小雪',min:0.1,max:2.4,src:'images/weather-snow.png'},
	{text:'中雪',min:2.5,max:4.9,src:'images/weather-snow.png'},
	{text:'大雪',min:5,max:9.9,src:'images/weather-snow.png'},
	{text:'暴雪',min:10.0,max:19.9,src:'images/weather-snow.png'},
	{text:'大暴雪',min:20,max:29.9,src:'images/weather-snow.png'},
	{text:'特大暴雪',min:30,max:10000,src:'images/weather-snow.png'}
]
var RAIN_AREA=[
	{text:'小雨',min:0.1,max:9.9,src:'images/weather-largerain.png'},
	{text:'中雨',min:10,max:24.9,src:'images/weather-largerain.png'},
	{text:'大雨',min:25,max:49.9,src:'images/weather-largerain.png'},
	{text:'暴雨',min:50.0,max:99.9,src:'images/weather-largerain.png'},
	{text:'大暴雨',min:100,max:249.9,src:'images/weather-largerain.png'},
	{text:'特大暴雨',min:250,max:10000,src:'images/weather-largerain.png'}
]
/**
 * 24小时天气
 * @param {Object} rain	24小时合计降雨量
 * @param {Object} snow	24小时合计降雪量
 * @param {Object} cloud云量
 */
function getWeatherStr(rain,snow,cloud){
	var r=rain<=0.1?0:rain;
	var s=snow<=0.1?0:snow;
	var c=cloud;
	if(r!=0 && s==0){	//降雨
		for(var i=0;i<RAIN_AREA.length;i++){
			if(r>RAIN_AREA[i].min && r<RAIN_AREA[i].max){
				return RAIN_AREA[i];
			}
		}
		return RAIN_AREA[0];
	}else if(r==0 && s!=0){	//降雪
		for(var i=0;i<SNOW_AREA.length;i++){
			if(s>SNOW_AREA[i].min && s<SNOW_AREA[i].max){
				return SNOW_AREA[i];
			}
		}
		return SNOW_AREA[0];
	}else{
		for(var i=0;i<CLOUD_AREA.length;i++){
			if(c>=CLOUD_AREA[i].min && c<CLOUD_AREA[i].max && rain==0 && snow==0){
				return CLOUD_AREA[i];
			}
		}
		return CLOUD_AREA[0];
	}
}

function getWinD(wd,ws){
	var res={};
	for(var i=0;i<WIND_ARR_DICT.length;i++){
		var dict=WIND_ARR_DICT[i];
		if((wd>=WIND_ARR_DICT[0].sr && wd<=360) || (wd>=0 && wd<=WIND_ARR_DICT[0].er)){
			res.wd=dict;
			break;
		}
		if(wd>=dict.sr && wd<=dict.er){
			res.wd=dict;
			break;
		}
	}
	for(var i=0;i<WIND_SU_DICT.length;i++){
		var dict=WIND_SU_DICT[i];
		if(ws>=dict.ss &&dict.es!=null && ws<=dict.es){
			res.ws=dict;
			break;
		}else if(dict.es==null && ws>=dict.ss){
			res.ws=dict;
			break;
		}
	}
	
	return res;
	
}
